
package com.microweb.toastmaster.service.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.microweb.toastmaster.service.impl.BaseManager;
import com.microweb.toastmaster.model.TMRole;
import com.microweb.toastmaster.dao.TMRoleDao;
import com.microweb.toastmaster.service.TMRoleManager;

public class TMRoleManagerImpl extends BaseManager implements TMRoleManager {
    private final Log log = LogFactory.getLog(TMRoleManagerImpl.class);
    private TMRoleDao dao;

    /**
     * Set the Dao for communication with the data layer.
     * @param dao
     */
    public void setTMRoleDao(TMRoleDao dao) {
        this.dao = dao;
    }

    /**
     * @see com.microweb.toastmaster.service.TMRoleManager#getTMRoles(com.microweb.toastmaster.model.TMRole)
     */
    public List getTMRoles(final TMRole tMRole) {
	log.debug("in TMRoleManagerImpl.getTMRoles.");
        return dao.getTMRoles(tMRole);
    }

    /**
     * @see com.microweb.toastmaster.service.TMRoleManager#getTMRole(String id)
     */
    public TMRole getTMRole(final String id) {
        return dao.getTMRole(new Long(id));
    }
    
    public TMRole getTMRoleByName(final String rolename) throws Exception {
	return dao.getTMRoleByName(rolename);
    }

    /**
     * @see com.microweb.toastmaster.service.TMRoleManager#saveTMRole(TMRole tMRole)
     */
    public void saveTMRole(TMRole tMRole) {
        dao.saveTMRole(tMRole);
    }

    /**
     * @see com.microweb.toastmaster.service.TMRoleManager#removeTMRole(String id)
     */
    public void removeTMRole(final String id) {
        dao.removeTMRole(new Long(id));
    }
    
    
}
